package com.block.sms.service.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.sms.enums.SmsTypeEnum;
import com.block.sms.service.ISmsSendService;
import com.block.sms.service.send.DefaultProcessServiceImpl;
import com.block.sms.service.send.*;

import java.util.HashMap;
import java.util.Map;

public class SmsSendFactory {


    private static Map<String, Class<? extends ISmsSendService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(SmsTypeEnum.DEFAULT.getValue(), DefaultProcessServiceImpl.class);
        serviceMap.put(SmsTypeEnum.MIAOXIN.getValue(), MiaoXinSmsSendServiceImpl.class);
        serviceMap.put(SmsTypeEnum.WOLIAN.getValue(), WoLianSmsSendServiceImpl.class);
        serviceMap.put(SmsTypeEnum.YIMEI.getValue(), YiMeiSmsSendServiceImpl.class);

    }

    public static ISmsSendService getService(String smsType){

        if (serviceMap.containsKey(smsType)){
            Class<? extends ISmsSendService> aClass = serviceMap.get(smsType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultProcessServiceImpl.class);
    }


}
